<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>五指山污水处理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/public.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/images/favicon.ico"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-card">
            <div class="layui-card-body">
                <blockquote class="layui-elem-quote">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input class="layui-input searchval" type="text" placeholder="请输入搜索的内容">
                        </div>
                        <button class="layui-btn" id="search_btn" data-type="reload">搜索</button>
                    </div>
                </blockquote>
                <table class="layui-hide" id="chemicalTable" lay-filter="chemicalTables"></table>
                <div id="laypage"></div>
            </div>
        </div>
    </div>
</div>
<input type="hidden" id="curnum" value="1">
<script type="text/html" id="chemicalOperation">
    <div class="layui-inline" lay-event="add" title="添加">
        <i class="layui-icon layui-icon-add-1"></i>
    </div>
</script>
<script type="text/html" id="table-chemical">

</script>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['table', 'user', 'layer', 'form', ], function () {
        var $ = layui.jquery,
            table = layui.table,
            dtree = layui.dtree,
            layer = layui.layer,
            form = layui.form
            , laypage = layui.laypage

        var limitcount = 10;

        //搜索事件
        var active = {
            reload: function () {  //data-type='reload'
                var searchval = $('.searchval').val();
                $("#curnum").val("1");
                table.reload('chemicalTable', { //表格的id
                    where: {
                        key: searchval,
                        page: 1,
                        limit: 10,
                    },
                    text: {
                        none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                    }
                })
            }
        };

        $('#search_btn').on('click', function () { //搜索的id
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        table.render({
            elem: '#chemicalTable'
            , url:  "<%=request.getContextPath()%>/rest/base/getDtuSendList"
            , toolbar: '#chemicalOperation'
            , height: 'full-200'
            , title: 'dtu数据发送记录'
            , defaultToolbar: ['filter', 'print']
            , cols: [[
                {title: 'ID', width: 70, sort: true, fixed: 'left', type: 'numbers'},
                {field: 'number', title: 'dtu编号', sort: true ,width: 200},
                {field: 'cun', title: '自然村', sort: true,width: 200},
                {field: 'sendTimeString', title: '接收时间', sort: true ,width: 200},
                {field: 'csb', title: '产水泵状态', sort: true,width: 150},
                {field: 'csbrun', title: '运行时间', sort: true,width: 150},
                {field: 'csbend', title: '停止时间', sort: true,width: 150},
                {field: 'hlb', title: '回流泵状态', sort: true,width: 150},
                {field: 'hlbrun', title: '运行时间', sort: true,width: 150},
                {field: 'hlbend', title: '停止时间', sort: true,width: 150},
                {field: 'fxb', title: '反洗泵状态', sort: true,width: 150},
                {field: 'fxbrun', title: '运行时间', sort: true,width: 150},
                {field: 'fxbend', title: '停止时间', sort: true,width: 150},
                {field: 'jbj', title: '搅拌机状态', sort: true,width: 150},
                {field: 'jbjrun', title: '运行时间', sort: true,width: 150},
                {field: 'jbjend', title: '停止时间', sort: true,width: 150},
                {field: 'gfj', title: '鼓风机状态', sort: true,width: 150},
                {field: 'gfjrun', title: '运行时间', sort: true,width: 150},
                {field: 'gfjend', title: '停止时间', sort: true,width: 150}

                ]]
            , page: false
            , limit: limitcount
            , text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            },
            // limits:[10, 20, 30, 40, 50],
            done: function (res, curr, count) {
                if (res.errorMsg == null) {

                } else {
                    layer.msg(res.errorMsg);
                }
                var curnum = $("#curnum").val();
                $('.layui-table-fixed-r').removeClass('layui-hide');//列固定右侧
                laypage.render({
                    elem: 'laypage'
                    , first: '首页'
                    , last: '尾页'
                    , groups: 5
                    , count: count
                    , curr: curnum
                    , limit: limitcount
                    , layout: ['prev', 'page', 'next', 'skip', 'count', 'limit']
                    , limits: [10, 15, 20]
                    , jump: function (obj, first) {
                        if (!first) {
                            curnum = obj.curr;
                            $("#curnum").val(curnum)
                            limitcount = obj.limit;
                            table.reload('chemicalTable', { //表格的id
                                where: {
                                    page: curnum,
                                    limit: limitcount
                                }
                            })

                        }
                    }
                })
            }
        })
    });
</script>
</body>
</html>
